package com.ec.bl.domain.entity;

import com.baomidou.mybatisplus.annotation.*;
// 确保导入了 EnumValue 注解
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue; // 建议也加上这个，下面会解释
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("refund_records")
public class RefundRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField("bill_id")
    private Long billId;

    @TableField("elderly_user_id")
    private Long elderlyUserId;

    @TableField("amount")
    private BigDecimal amount;

    @TableField("reason")
    private String reason;

    @TableField("status")
    private RefundStatus status;

    @TableField("refund_time")
    private LocalDateTime refundTime;

    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    public enum RefundStatus {
        PENDING("pending"),
        APPROVED("approved"),
        REJECTED("rejected"),
        COMPLETED("completed");

        @EnumValue // <--- 关键！添加这个注解
        @JsonValue   // <--- 强烈建议也加上这个
        private final String value;

        RefundStatus(String value) {
            this.value = value;
        }

        // getValue() 方法可以保留，也可以去掉，MyBatis-Plus/Jackson会通过反射直接访问字段
        public String getValue() {
            return value;
        }
    }
}